
package com.example.app2.web;

import com.example.app2.feign.App1FeignClient;
import com.example.app2.pojo.RestResp;
import com.example.app2.pojo.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.*;

@RestController
public class BasicController {

    @Autowired
    App1FeignClient app1FeignClient;

    @GetMapping("/hello")
    @ResponseBody
    public String hello(@RequestParam(name = "name", defaultValue = "unknown user") String name) {
        return app1FeignClient.hello(name);
    }

    // 1.测试feign拦截器传递 审计信息
    // 2.测试feign解码器，从统一响应对象中解析出data
    //  audit这个方法，服务端返回的是RestResp对象，data中是个字符串，feign接口中的方法本来应该也返回RestResp对象
    //  使用feign解码器自动解析出data
    @PostMapping("/audit")
    public String audit(){
        return app1FeignClient.audit();
    }

}
